<?php

putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors', 1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'Api.php';

$skype    = $argv[1];
$author   = urldecode($argv[2]);
$title    = urldecode($argv[3]);
$public   = urldecode($argv[4]);
$publicId = $argv[5];
$postId   = $argv[6];

if (!$skype) {
    exit();
}

$dbus = new Dbus(Dbus::BUS_SESSION, true);
$n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
$n->Invoke('NAME SEND_ASSIGN');
$n->Invoke('PROTOCOL 8');
$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Bot');

$msg = 'Добавлена новость. ' . "\n";
$msg .= 'Рубрика: '  . iconv("WINDOWS-1251","UTF-8", $public) . "\n";
$msg .= 'Автор: '    . iconv("WINDOWS-1251","UTF-8", $author) . "\n";
$msg .= 'Название: ' . iconv("WINDOWS-1251","UTF-8", $title)  . "\n";
$msg .= 'Ссылка: http://fotostrana.ru/staff/news/post/?id='. $publicId . '&post_id=' . $postId . "\n";

Bot::getInstance()->sendNotifyToSkype($skype, $msg);
exit();